<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name='viewport' content='width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no'>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- 引入公共样式 -->
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/coupon.css">
    <link rel="stylesheet" href="../fonts/iconfont.css">
    <script src="../js/htmlFont.js"></script>
    <title>优惠券</title>
</head>

<body>
    <!-- 头部 -->
    <header>
        <div class="header-top">
            <span class="iconfont icon-fanhui"></span>
            <h3>优惠券</h3>
            <img src="../images/header_app.png" alt="">
        </div>
    </header>
    <!-- 中间内容区 -->
    <div class="content_nav">
        <ul id="cont_nav">

        </ul>
    </div>

    <!-- 底部 -->
    <footer>
        <div class="brand">
            <p>首页>优惠卷</p>
            <a class="fa fa-chevron-right" href="javascript:;"></a>
        </div>
        <div class="footer-top">
            <ul>
                <li>登录</li>
                <li>注册</li>
                <li class="go">返回顶部</li>
            </ul>
        </div>
        <div class="footer-footer">
            <div class="shouji">
                <a href="javascript:;">手机APP下载</a>
                <a href="javascript:;"> 慢慢买手机版</a>
                <a href="javascript:;">-掌上比价平台</a>
            </div>
            <a href="javascript:;">m.mammambuy.com</a>
        </div>
    </footer>
</body>

</html>
<script src="../lib/jquery/jquery-1.12.4.js"></script>
<script src="../lib/template/template.js"></script>
<!-- <script src="../js/coupon.js"></script> -->
<script type="text/template" id="coupTemp">
    <!-- 创建模版 -->
    {{each result as val key}}
    <li>
        <a href="./coupon_list.html?id={{val.couponId}}" class="couponId" index-id="{{val.couponId}}"><img src="{{val.couponImg}}" alt="">
            <span>{{val.couponTitle}}</span>
        </a>
    </li>
    {{/each}}
</script>
<script>
    $(function() {
        $.ajax({
            type: "get",
            url: "http://193.112.55.79:9090/api/getcoupon",
            dataType: "jsonp",
            success: function(res) {
                console.log(res);
                // 建立模版对象
                var htmlStr = template("coupTemp", res);
                // 渲染数据
                $('#cont_nav').html(htmlStr);
            }
        });
    })
</script>